﻿namespace JxcLite.Pages.BillData;

class BillPrint : ComponentBase
{
    [Parameter] public BillInfo Model { get; set; }

    protected override void BuildRenderTree(RenderTreeBuilder builder)
    {
        BuildStyle(builder);
        BuildForm(builder);
    }

    private static void BuildStyle(RenderTreeBuilder builder)
    {
        builder.Markup(@"<style>
.bill-print {position:relative;}
.bill-print canvas {position:absolute;top:0;right:0;width:180px;height:40px;}
.bill-print .txt-right {text-align:right;}
.bill-print .field {display:grid;grid-template-columns:repeat(auto-fit,minmax(0%,1fr));grid-column-gap:10px;margin:10px 0;}
.bill-print .title {font-size:1.5rem;font-weight:bold;text-align:center;}
.bill-print .content {height:100px;border-top:2px solid #ccc;;border-bottom:1px solid #ccc;padding:10px;}
</style>");
    }

    private void BuildForm(RenderTreeBuilder builder)
    {
        builder.Div("bill-print", () =>
        {
            builder.Div("title", $"XXX公司{Model.Type}单");
            builder.Div("field", () =>
            {
                builder.Div("", $"业务单号：{Model.BillNo}");
                builder.Div("txt-right", $"单证日期：{Model.BillDate:yyyy-MM-dd}");
            });
            builder.Div("content", () =>
            {
                
            });
            builder.Div("field", () =>
            {
                builder.Div("", $"制单人：{Model.CreateBy}");
                builder.Div("", $"制单日期：{Model.CreateTime:yyyy-MM-dd}");
            });
        });
    }
}